package low;

import java.util.Arrays;

/**
 *283. 移动零
 */
public class MoveZeroes {
    public static void main(String[] args) {
        int[] nums = new int[]{-4,-1,0,3,10};
        int[] arrays = moveZeroes(nums);
        System.out.println(Arrays.toString(arrays));
    }

    public static int[] moveZeroes(int[] nums) {
        int index = 0;
        for(int num:nums){
            if (num!=0){
                nums[index++] = num;
            }
        }
        for (int i=index;i<nums.length;i++){
            nums[i] = 0;
        }
        return nums;
    }
}
